//
//  RecorderManager.h
//  LinkUsMessage_iOS
//
//  Created by lcy on 15/12/31.
//  Copyright © 2015年 lcy. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>

@protocol RecordingDelegate <NSObject>

- (void)recordingFinishedWithFileName:(NSString *)filePath time:(NSTimeInterval)interval;  // 录音完成
- (void)recordingTimeout;  // 超时
- (void)recordingStopped;  //录音机停止采集声音
- (void)recordingFailed:(NSString *)failureInfoString;  // 录音失败

@optional

- (void)levelMeterChanged:(float)levelMeter;

@end

@interface LCYRecorderManager : NSObject

@property (nonatomic, weak)  id<RecordingDelegate> delegate;
@property (nonatomic, strong) AVAudioRecorder *recorder;  // 录音
@property (nonatomic, strong) AVAudioPlayer *audioPlayer; // 音频播放
@property (nonatomic, strong) NSDate *dateStartRecording, *dateStopRecording;
@property (copy, nonatomic) NSString *fileName;
@property (nonatomic) BOOL isStop; // 是否录音停止（停止的话要刷新创建和结束时间）
@property (assign, nonatomic) double recordDurationTime; // 录音时长
@property (strong, nonatomic) NSTimer *recordTimer; // 录音计时器

- (void)startRecording;

- (void)stopRecording;

- (void)cancelRecording;

//播放
- (void)play;

//停止
- (void)stop;

/**
 *  初始化播放器
 *
 *  @param urlStr 音频链接
 */
- (void)initAudioPlayerWithUrl:(NSString *)urlStr;

- (NSTimeInterval)recordedTimeInterval;

/**
 *  音频文件名
 *
 *  @return 文件名
 */
- (NSString *)defaultFileName;

@end

